#pragma once
#include <Windows.h>
#include <string>
#include <mutex>
#include <json/json.h>

#define VX_ERROR (-1)
#define VX_OK    (1)

class VxDriver
{
public:
	VxDriver ();
	~VxDriver ();
	int DriveInit ();
	int GetUserWxWorkVersion (BYTE * ver);
	int UseUtf8 ();
	int UseRecvJsUnicode ();
	int InitWxWorkSocket (void * pAccpetCallback, void * pRecvCallback, void * pCloseCallback);
	int InjectWxWork(const char* dllPath = NULL, const char* WxWorkExePath = NULL);
	int InjectWxWorkPid (int pid, const char* WxWorkExePath = NULL);
	int InjectWxWorkMultiOpen(const char* dllPath = NULL, const char* WxWorkExePath = NULL);
	int SendWxWorkData (int dwClientId, const char* szJsonData);
	int SendMsg(int dwClientId, int dwOPCode, Json::Value& szJsonData);
	int DestroyWxWork ();
	bool IsSupport();
	int dyn_API_Invoke(const char* funcName);
	void AutoHook();

private:
	HMODULE      m_VxApiModule = nullptr;
	bool         m_VersionIsSupport = false;
	std::string  m_VxWorkVersion = "Unknow";
	std::string  m_VxWorkHelperDllPath = "\\WxWorkHelper_4.0.2.6026.dll";
	std::mutex   m_syncLock;
};